<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="现金银行" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doSearch(){
		var startDate=document.getElementById("start_date").value;
		var endDate=document.getElementById("end_date").value;
		var tsId=document.getElementById("ts_id").value;
		var isTmp=document.getElementById("is_tmp").value;
		var searchKey=document.getElementById("search_key").value;
		
		if(startDate!=null && startDate!=''){
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return;
			}
		}else{
			ShowAlert('提示框','请选择开始日期',200,100);
			return;
		}
		if(endDate!=null && endDate!=''){
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				aShowAlert('提示框','结束日期格式不正确',200,100);
				return;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return;
			}
		}else{
			ShowAlert('提示框','请选择结束日期',200,100);
			return;
		}
		
		window.location="/finance/AccountBalanceList.ihtm?start_date="+startDate+"&end_date="+endDate+"&ts_id="+tsId+"&is_tmp="+isTmp+"&search_key="+encodeURIComponent(searchKey);
	}
	
	function getSearchCondition(){
		var searchKey=encodeURIComponent("<c:out value="${searchKey}" />");
		var str="start_date=${startDate}&end_date=${endDate}&ts_id=${tsId}&is_tmp=${isTmp}&search_key="+searchKey;
		return str;
	}
	
	function doCancel(){
		window.close();
	}
	function doInit(){
		Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doDetail(baId,financeType,rcType){
		var startDate="${startDate}";
		var endDate="${endDate}";
		if(baId==""){
			baId="${baIdStr}";
		}
		showWin(900,600,"/finance/AccountDetailList.ihtm?ba_id="+baId+"&finance_type="+financeType+"&rc_type="+rcType+"&start_date="+startDate+"&end_date="+endDate+"&list_type=BILL");
	}
	function doLogList(baId){
		var startDate="${startDate}";
		var endDate="${endDate}";
		if(baId==""){
			baId="${baIdStr}";
		}
		showWin(900,600,"/finance/AccountLogList.ihtm?ba_id="+baId+"&start_date="+startDate+"&end_date="+endDate);
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/finance/AccountBalanceList.ihtm?content_type=EXCEL&"+str;
	}
	function setDate(type){
		var d=new Date();
		var startStr="";
		var endStr="";
		if(type=="CURRENT_MONTH"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-01";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-1";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="TODAY"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="YESTERDAY"){
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}
		document.getElementById("start_date").value=startStr;
		document.getElementById("end_date").value=endStr;
	}
</script>
</head>
<c:set var="showLink" value="Y" />
<c:if test="${fn:indexOf(currentUser.privs,';BUSI_SELF;')!=-1 || fn:indexOf(currentUser.privs,';NO_EARL_DATA;')!=-1}">
	<c:set var="showLink" value="N" />
</c:if>
<body onLoad="doInit();" class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:980px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>现金银行</h2>
      <p>查询当前各个银行账户余额及收支明细</p>
    </div>
  </div>
  <div class="sheet-list">
    	<div class="search-business">
			      <div class="content">
			        <table width="868">
			          <tbody>
			            <tr>
			              <td>
							日期：<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" id="start_date" name="start_date" value="${startDate}">
							<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this);">
							至<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" id="end_date" name="end_date" value="${endDate}">
							<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this);">
							
							<select name="ts_id" id="ts_id">
								<option value="0">==请选择帐套==</option>
								<c:forEach var="item" items="${tsList}">
									<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option>
								</c:forEach>
				  			</select>
				  			<select name="is_tmp" id="is_tmp">
				  				<option value="">==全部帐户==</option>
				  				<option value="Y" <c:if test="${isTmp=='Y'}">selected</c:if>>现金账户</option>
				  				<option value="N" <c:if test="${isTmp=='N'}">selected</c:if>>非现金账户</option>
				  			</select>
				  			<input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkInput();" style="width:80px" value="${searchKey}" title="以开户名、开户银行进行模糊查询">
				  						
							<input type="button"  value=" 查 询" onClick="doSearch();"  class="buttom search-but">
							<input type="button"  value=" 导 出" onClick="doDownload();" class="buttom  search-out" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>								
						  </td>
			            </tr>
			            <tr>
			            	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				            	<a href="javascript:setDate('CURRENT_MONTH');">本月</a>
								<a href="javascript:setDate('TODAY');">今天</a>
								<a href="javascript:setDate('YESTERDAY');">昨天</a>
								<a href="javascript:setDate('PREVIEW_MONTH');">上月</a>
			            	</td>
			            </tr>
			            </tbody>      
			        </table>      	 
			      </div>	
			      <div class="table-list">	
			        <table width="100%">
			          	<tr>
							<th  width="8%" rowspan="2">账户名称</th>
							<th  width="8%" rowspan="2">期初余额</th>
							<th  width="30%" colspan="5">收入</th>
							<th  width="36%" colspan="6">支出</th>
							<th  width="8%" rowspan="2">期末余额</th>
							<th  width="6%" rowspan="2">增加额</th>
							<th  width="4%" rowspan="2">操作</th>
						</tr>
						<tr>
							<th  width="6%">业务</th>
							<th  width="6%">其他</th>
							<th  width="6%">借入</th>
							<th  width="6%">转入</th>
							<th  width="6%">小计</th>
							<th  width="6%">采购</th>
							<th  width="6%">外协</th>
							<th  width="6%">费用</th>
							<th  width="6%">借出</th>
							<th  width="6%">转出</th>
							<th  width="6%">小计</th>
						</tr>
						<c:forEach var="item" items="${list}" varStatus="i">
						<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
						<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
						<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
							<td>${item.accountName}</td>
							<td><commonTag:parseBigDecimal source="${item.startCost}" /></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','BUSINESS','R');"></c:if><commonTag:parseBigDecimal source="${item.busCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','INCOME','R');"></c:if><commonTag:parseBigDecimal source="${item.incomeCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','LOAN_IN','R');"></c:if><commonTag:parseBigDecimal source="${item.loanInCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','TRANSFER_IN','R');"></c:if><commonTag:parseBigDecimal source="${item.tranInCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','','R');"></c:if><commonTag:parseBigDecimal source="${item.recCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','PURCHASE','P');"></c:if><commonTag:parseBigDecimal source="${item.purCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','COOPER','P');"></c:if><commonTag:parseBigDecimal source="${item.cooCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','FEE','P');"></c:if><commonTag:parseBigDecimal source="${item.feeCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','LOAN_OUT','P');"></c:if><commonTag:parseBigDecimal source="${item.loanOutCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','TRANSFER_OUT','P');"></c:if><commonTag:parseBigDecimal source="${item.tranOutCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','','P');"></c:if><commonTag:parseBigDecimal source="${item.expCost}" /><c:if test="${showLink=='Y'}"></a></c:if></td>
							<td><commonTag:parseBigDecimal source="${item.endCost}" /></td>
							<td><commonTag:parseBigDecimal source="${item.recCost-item.expCost}" /></td>
							<td>
								<c:if test="${showLink=='Y'}"><a href="javascript:doDetail('${item.accountId}','','');"></c:if>明细<c:if test="${showLink=='Y'}"></a></c:if>
								<br>
								<c:if test="${showLink=='Y'}"><a href="javascript:doLogList('${item.accountId}');"></c:if>日志<c:if test="${showLink=='Y'}"></a></c:if>
							</td>
						</tr>
						</c:forEach>
						<tr>
							<th>合计</th>
							<th><commonTag:parseBigDecimal source="${totalBean.startCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.busCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.incomeCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.loanInCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.tranInCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.recCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.purCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.cooCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.feeCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.loanOutCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.tranOutCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.expCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.endCost}" /></th>
							<th><commonTag:parseBigDecimal source="${totalBean.recCost-totalBean.expCost}" /></th>
							<th><c:if test="${showLink=='Y'}"><a href="javascript:doDetail('','','');"></c:if>明细<c:if test="${showLink=='Y'}"></a></c:if></th>
						</tr>
					</table>
				 </div>	
 		 </div>
   </div>
<div>
</body>
</html>
